$(function () {
    //加载默认隐藏展示页
    $(".show").hide()
    //单击后获取输入内容
    $(".btn").bind("click", function () {
        var title = $(".title").val();
        var text = $(".text").val();
        console.log(title)
        console.log(text)

        $.ajax({
            type: "post",
            url: "/nlp?action=artLabel",
            data: {
                title: title,
                text: text
            },
            dataType: "json",
            success: function (data) {
                console.log(data);
                //遍历data中的item
                var len = data.items.length;
                console.log(len)
                var htmlStr = "";
                for (var i = 0; i < len; i++) {
                    htmlStr += "<div class=\"bottom_div\">标签：<span class=\"right_span\">" + data.items[i].tag + "</span></div>"
                    htmlStr += " <div class=\"bottom_div\">权重：<span class=\"right_span\">" + data.items[i].score + "</span></div>"
                }
                //拼接到页面上
                $(".show").html(htmlStr);

            },
            error: function (err) {
                alert("网络异常")
                console.log("失败")
            }
        })
        //单击后展示隐藏页面
        $(".show").show()
    })

})



